<template>
  <div class="add-card">
    <header class="add-header">
      <el-page-header @back="$router.back()" />
      <span>{{ cardTitle }}</span>
    </header>
    <main class="add-main">
      <div class="form-container">
        <div class="title">告警详情</div>
        <div class="form">
          <el-descriptions column="2">
            <el-descriptions-item label="告警时间">
              {{ form.warningTime }}
            </el-descriptions-item>
            <el-descriptions-item label="一体杆名称">
              {{ form.poleName }}
            </el-descriptions-item>
            <el-descriptions-item label="告警区域">
              {{ form.areaName }}
            </el-descriptions-item>
            <el-descriptions-item label="一体杆编号">
              {{ form.poleNumber }}
            </el-descriptions-item>
            <el-descriptions-item label="故障类型">
              {{ form.errorType }}
            </el-descriptions-item>
            <el-descriptions-item label="处置状态">
              {{ form.handleStatus }}
            </el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
      <div class="form-container">
        <div class="title">告警处理</div>
        <div class="form">
          <el-descriptions column="2">
            <el-descriptions-item label="处理人">
              {{ form2.handleUser }}
            </el-descriptions-item>
            <el-descriptions-item label="联系方式">
              {{ form2.phonenumber }}
            </el-descriptions-item>
            <el-descriptions-item label="处理结果">
              {{ form2.handleResult }}
            </el-descriptions-item>
            <el-descriptions-item label="完成时间">
              {{ form2.handleTime }}
            </el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
    </main>
  </div>
</template>

<script>
import { getRodWarnAPI } from '@/api/warn';

export default {
  data() {
    return {
      cardTitle: '详情查看',
      form: {
        warningTime: '',
        poleName: '',
        areaName: '',
        poleNumber: '',
        errorType: '',
        handleStatus: ''
      },
      form2: {
        handleUser: '',
        phonenumber: '',
        handleResult: '',
        handleTime: ''
      }
    };
  },
  mounted() {
    console.log('页面加载了……');

    const id = this.$route.query.id;
    console.log(id);
    if (id) {
      getRodWarnAPI(id).then((res) => {
        console.log(res);

        this.form.warningTime = res.data.warningTime;
        this.form.poleName = res.data.poleName;
        this.form.areaName = res.data.areaName;
        this.form.poleNumber = res.data.poleNumber;
        this.form.errorType = res.data.errorType;
        this.form.handleStatus = res.data.handleStatus;

        this.form2.handleUser = res.data.handleUser;
        this.form2.phonenumber = res.data.phonenumber;
        this.form2.handleResult = res.data.handleResult;
        this.form2.handleTime = res.data.handleTime;
      });
    }
  }
};
</script>

<style scoped lang="scss">
.add-card {
  background-color: #f4f6f8;
  height: 100vh;

  .add-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 64px;
    background-color: #fff;

    .left {
      span {
        margin-right: 4px;
      }

      .arrow {
        cursor: pointer;
      }
    }

    .right {
      text-align: right;
    }
  }

  .add-main {
    background: #f4f6f8;
    padding: 20px 130px;

    .form-container {
      background-color: #fff;

      .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
      }

      .form {
        margin-bottom: 20px;
        padding: 20px 65px 24px;

        .el-form {
          display: flex;
          flex-wrap: wrap;

          .el-form-item {
            width: 50%;
          }
        }
      }
    }

    .preview {
      img {
        width: 100px;
      }
    }
  }

  .add-footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    padding: 24px 50px;
    color: #000000d9;
    font-size: 14px;
    background: #fff;
    text-align: center;
  }
}
</style>
